import { FlatCompat } from '@eslint/eslintrc';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
  baseDirectory: __dirname,
});

const eslintConfig = [
  ...compat.extends('next/core-web-vitals', 'next/typescript', 'prettier'),
  // 全局变量配置（Flat Config 格式）
  {
    languageOptions: {
      globals: {
        React: 'readonly',
      },
    },
  },

  // 自定义规则配置
  {
    rules: {
      'no-unused-vars': [1, { args: 'after-used', argsIgnorePattern: '^_' }],
    },
  },
];

export default [...eslintConfig, eslintConfigPrettier];
